package com.utils;

import java.io.IOException;
import java.net.URLEncoder;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedHashMap;

import org.json.JSONArray;
import org.json.JSONObject;

import com.zxy.common.Com_Fun;
import com.zxy.common.Com_Para;
import com.zxy.db_Self.Db_Common_Self;

public class T01_sel_t_proc_name implements com.zxy.common.ParamName_InterFace
{
	public StringBuilder	strResult		= new StringBuilder();
	public String			user_main_id			= null;
	public String			session_id		= null;
	public String			param_name		= null;
	public String			param_value1	= null;
	public String			param_value2	= null;
	public String			param_value3	= null;
	public String			param_value4	= null;
	public String			param_value5	= null;
	public String			param_value6	= null;
	public String			param_value7	= null;
	public String			param_value8	= null;
	public String			param_value9	= null;
	public String			param_value10	= null;

	@Override
	public void init_start()
	{
		// SELECT t_proc_name.MAIN_ID,t_db_config.DB_CN_NAME AS DB_ID
		// ,INF_CN_NAME,INF_EN_NAME,INF_EN_SQL,INF_TYPE,t_proc_name.S_DESC,t_proc_name.CREATE_DATE,REFLECT_IN_CLASS,REFLECT_OUT_CLASS
		// FROM t_proc_name left join t_db_config on t_proc_name.DB_ID =
		// t_db_config.MAIN_ID where t_proc_name.MAIN_ID > 87 or
		// t_proc_name.MAIN_ID = 63 order by t_proc_name.MAIN_ID asc

		Db_Common_Self dbc_self = new Db_Common_Self();
		String[] Parameters = new String[0]; // 参数
		String[] ParamTypes = new String[0];// 参数类型
		String[] ParamOutName = new String[0];
		String[] ParamOutType = new String[0];
		com.zxy.model.T_PROC_NAME trn = new com.zxy.model.T_PROC_NAME();
		trn.INF_TYPE = "2"; // Sql
		trn.INF_EN_SQL = "SELECT t_proc_name.MAIN_ID,t_db_config.DB_CN_NAME AS DB_ID,INF_CN_NAME,INF_EN_NAME,"
				+" INF_EN_SQL,INF_TYPE,t_proc_name.S_DESC,t_proc_name.CREATE_DATE,"
				+" REFLECT_IN_CLASS,REFLECT_OUT_CLASS,iS_MOCK,MOCK_DATA_COUNT "
				+" FROM t_proc_name left join t_db_config on t_proc_name.DB_ID = t_db_config.MAIN_ID "
				+" where t_proc_name.db_id != '1' or INF_EN_NAME = 'APP_USER_ZXY' order by t_proc_name.MAIN_ID asc";
		ResultSet rs = dbc_self.Common_Sql_Proc(param_name,Parameters,ParamTypes,ParamOutName,ParamOutType,trn);
		try
		{
			JSONObject jso = new JSONObject(new LinkedHashMap());
			JSONArray jsary = new JSONArray();
			while(rs.next())
			{
				JSONObject temjso = new JSONObject(new LinkedHashMap());
				temjso.put("MAIN_ID",rs.getInt("MAIN_ID"));
				temjso.put("DB_ID",rs.getString("DB_ID"));
				temjso.put("INF_CN_NAME",rs.getString("INF_CN_NAME"));
				temjso.put("INF_EN_NAME",rs.getString("INF_EN_NAME"));
				temjso.put("INF_EN_SQL",rs.getString("INF_EN_SQL"));// Com_Fun.Java_encode(URLEncoder.encode(rs.getString("INF_EN_SQL"),"UTF-8")));
				temjso.put("INF_TYPE",rs.getString("INF_TYPE"));
				temjso.put("S_DESC",rs.getString("S_DESC"));
				temjso.put("CREATE_DATE",rs.getString("CREATE_DATE"));
				temjso.put("REFLECT_IN_CLASS",rs.getString("REFLECT_IN_CLASS"));
				temjso.put("REFLECT_OUT_CLASS",rs.getString("REFLECT_OUT_CLASS"));
				temjso.put("iS_MOCK",rs.getInt("REFLECT_IN_CLASS"));
				temjso.put("MOCK_DATA_COUNT",rs.getInt("REFLECT_OUT_CLASS"));
				jsary.put(temjso);
			}
			jso.put(param_name,jsary);
			strResult.append(jso.toString());
		}
		catch(Exception e)
		{
			Com_Fun.debug_in(e,this.toString());
		}
		finally
		{
			if(rs != null)
			{
				try
				{
					rs.getStatement().close();
					rs.close();
				}
				catch(SQLException e)
				{
				}
			}
		}
	}

	public StringBuilder getStrResult()
	{
		return strResult;
	}

	public void setStrResult(StringBuilder strResult)
	{
		this.strResult = strResult;
	}

	public String getUser_main_id()
	{
		return user_main_id;
	}

	public void setUser_main_id(String user_main_id)
	{
		this.user_main_id = user_main_id;
	}

	public String getSession_id()
	{
		return session_id;
	}

	public void setSession_id(String session_id)
	{
		this.session_id = session_id;
	}

	public String getParam_name()
	{
		return param_name;
	}

	public void setParam_name(String param_name)
	{
		this.param_name = param_name;
	}

	public String getParam_value1()
	{
		return param_value1;
	}

	public void setParam_value1(String param_value1)
	{
		this.param_value1 = param_value1;
	}

	public String getParam_value2()
	{
		return param_value2;
	}

	public void setParam_value2(String param_value2)
	{
		this.param_value2 = param_value2;
	}

	public String getParam_value3()
	{
		return param_value3;
	}

	public void setParam_value3(String param_value3)
	{
		this.param_value3 = param_value3;
	}

	public String getParam_value4()
	{
		return param_value4;
	}

	public void setParam_value4(String param_value4)
	{
		this.param_value4 = param_value4;
	}

	public String getParam_value5()
	{
		return param_value5;
	}

	public void setParam_value5(String param_value5)
	{
		this.param_value5 = param_value5;
	}

	public String getParam_value6()
	{
		return param_value6;
	}

	public void setParam_value6(String param_value6)
	{
		this.param_value6 = param_value6;
	}

	public String getParam_value7()
	{
		return param_value7;
	}

	public void setParam_value7(String param_value7)
	{
		this.param_value7 = param_value7;
	}

	public String getParam_value8()
	{
		return param_value8;
	}

	public void setParam_value8(String param_value8)
	{
		this.param_value8 = param_value8;
	}

	public String getParam_value9()
	{
		return param_value9;
	}

	public void setParam_value9(String param_value9)
	{
		this.param_value9 = param_value9;
	}

	public String getParam_value10()
	{
		return param_value10;
	}

	public void setParam_value10(String param_value10)
	{
		this.param_value10 = param_value10;
	}
}
